﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

public class FlyItemArtilleryObject : FlyItemObject
{
    public override void Emit(WeaponObject weaponObj)
    {
        base.Emit(weaponObj);
        var flyItem = weaponObj.weapon.GetSelectedFlyItem();
        var artillery = flyItem as FlyItemArtillery;
        if (artillery == null)
            return;
        var rigibody = GetComponent<Rigidbody2D>();
        float shottingOffset = weaponObj.weapon.GetShotingOffsetRandom;
        var emitDir = Quaternion.AngleAxis(weaponObj.weapon.GetShotingOffsetRandom, Vector3.forward) * weaponObj.transform.up.normalized;
        rigibody.AddForce(emitDir * artillery.CalcEmitForce());
        transform.rotation = weaponObj.transform.rotation * Quaternion.AngleAxis(-shottingOffset, Vector3.forward);
        m_EmitStartPos = transform.position;
        m_FlyDistance = 0;
    }
} 